package day01

// day01
//
// 509. 斐波那契数
//
// https://leetcode.cn/problems/fibonacci-number/
//
// ```go
func fib(n int) int {
	if n < 2 {
		return n
	}
	dp := make([]int, n+1)
	dp[0] = 0
	dp[1] = 1
	for i := 2; i <= n; i++ {
		dp[i] = dp[i-1] + dp[i-2]
	}
	return dp[n]
}

//```

// 70. 爬楼梯
//
// https://leetcode.cn/problems/climbing-stairs/
//
// ```go
func climbStairs(n int) int {
	dp := make([]int, n+1)
	//dp[i] = dp[i-1] + dp[i-2]
	dp[0] = 1
	dp[1] = 1
	for i := 2; i <= n; i++ {
		dp[i] = dp[i-1] + dp[i-2]
	}
	return dp[n]
}

//```

// 746. 使用最小花费爬楼梯
//
// https://leetcode.cn/problems/min-cost-climbing-stairs/
//
// ```go
func minCostClimbingStairs(cost []int) int {
	//dp[i] = min(dp[i-1], dp[i-2])
	dp := make([]int, len(cost)+1)
	dp[0] = 0
	dp[1] = 0
	for i := 2; i <= len(cost); i++ {
		dp[i] = min(dp[i-1]+cost[i-1], dp[i-2]+cost[i-2])
	}
	return dp[len(cost)]
}

//```
